/**
 */
package de.thwildau.tm.moses.avro.avdl.impl;

import de.thwildau.tm.moses.avro.avdl.AvdlPackage;
import de.thwildau.tm.moses.avro.avdl.ImportTypeRef;
import de.thwildau.tm.moses.avro.avdl.Imports;
import de.thwildau.tm.moses.avro.avdl.StringRef;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Imports</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ImportsImpl#getImportType <em>Import Type</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ImportsImpl#getImportURI <em>Import URI</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.avro.avdl.impl.ImportsImpl#getEndLine <em>End Line</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ImportsImpl extends MinimalEObjectImpl.Container implements Imports
{
  /**
   * The cached value of the '{@link #getImportType() <em>Import Type</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getImportType()
   * @generated
   * @ordered
   */
  protected ImportTypeRef importType;

  /**
   * The cached value of the '{@link #getImportURI() <em>Import URI</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getImportURI()
   * @generated
   * @ordered
   */
  protected StringRef importURI;

  /**
   * The default value of the '{@link #getEndLine() <em>End Line</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEndLine()
   * @generated
   * @ordered
   */
  protected static final String END_LINE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getEndLine() <em>End Line</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEndLine()
   * @generated
   * @ordered
   */
  protected String endLine = END_LINE_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ImportsImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AvdlPackage.Literals.IMPORTS;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ImportTypeRef getImportType()
  {
    return importType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetImportType(ImportTypeRef newImportType, NotificationChain msgs)
  {
    ImportTypeRef oldImportType = importType;
    importType = newImportType;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AvdlPackage.IMPORTS__IMPORT_TYPE, oldImportType, newImportType);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setImportType(ImportTypeRef newImportType)
  {
    if (newImportType != importType)
    {
      NotificationChain msgs = null;
      if (importType != null)
        msgs = ((InternalEObject)importType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.IMPORTS__IMPORT_TYPE, null, msgs);
      if (newImportType != null)
        msgs = ((InternalEObject)newImportType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.IMPORTS__IMPORT_TYPE, null, msgs);
      msgs = basicSetImportType(newImportType, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.IMPORTS__IMPORT_TYPE, newImportType, newImportType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public StringRef getImportURI()
  {
    return importURI;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetImportURI(StringRef newImportURI, NotificationChain msgs)
  {
    StringRef oldImportURI = importURI;
    importURI = newImportURI;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AvdlPackage.IMPORTS__IMPORT_URI, oldImportURI, newImportURI);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setImportURI(StringRef newImportURI)
  {
    if (newImportURI != importURI)
    {
      NotificationChain msgs = null;
      if (importURI != null)
        msgs = ((InternalEObject)importURI).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.IMPORTS__IMPORT_URI, null, msgs);
      if (newImportURI != null)
        msgs = ((InternalEObject)newImportURI).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AvdlPackage.IMPORTS__IMPORT_URI, null, msgs);
      msgs = basicSetImportURI(newImportURI, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.IMPORTS__IMPORT_URI, newImportURI, newImportURI));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getEndLine()
  {
    return endLine;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEndLine(String newEndLine)
  {
    String oldEndLine = endLine;
    endLine = newEndLine;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AvdlPackage.IMPORTS__END_LINE, oldEndLine, endLine));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AvdlPackage.IMPORTS__IMPORT_TYPE:
        return basicSetImportType(null, msgs);
      case AvdlPackage.IMPORTS__IMPORT_URI:
        return basicSetImportURI(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AvdlPackage.IMPORTS__IMPORT_TYPE:
        return getImportType();
      case AvdlPackage.IMPORTS__IMPORT_URI:
        return getImportURI();
      case AvdlPackage.IMPORTS__END_LINE:
        return getEndLine();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AvdlPackage.IMPORTS__IMPORT_TYPE:
        setImportType((ImportTypeRef)newValue);
        return;
      case AvdlPackage.IMPORTS__IMPORT_URI:
        setImportURI((StringRef)newValue);
        return;
      case AvdlPackage.IMPORTS__END_LINE:
        setEndLine((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.IMPORTS__IMPORT_TYPE:
        setImportType((ImportTypeRef)null);
        return;
      case AvdlPackage.IMPORTS__IMPORT_URI:
        setImportURI((StringRef)null);
        return;
      case AvdlPackage.IMPORTS__END_LINE:
        setEndLine(END_LINE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AvdlPackage.IMPORTS__IMPORT_TYPE:
        return importType != null;
      case AvdlPackage.IMPORTS__IMPORT_URI:
        return importURI != null;
      case AvdlPackage.IMPORTS__END_LINE:
        return END_LINE_EDEFAULT == null ? endLine != null : !END_LINE_EDEFAULT.equals(endLine);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (endLine: ");
    result.append(endLine);
    result.append(')');
    return result.toString();
  }

} //ImportsImpl
